package edu.dali.enterprise_test.service.customer;

import com.github.pagehelper.Page;
import edu.dali.enterprise_test.dao.mapper.customer.CustomerMapper;
import edu.dali.enterprise_test.model.Pager;
import edu.dali.enterprise_test.model.vo.Dto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CustomerServiceImpl implements CustomerService {

    @Autowired
    private CustomerMapper customerMapper;

    @Override
    public Pager<Dto> selectList(Dto dto) {
        Pager<Dto> p = new Pager<>();
        List<Dto> data = customerMapper.selectList(dto);
        p.setData(data);
        int count = (int)((Page) data).getTotal();
        p.setCount(count);
        p.setMsg("");
        p.setCode(0);
        return p;
    }
}
